<?php

namespace app\v1\model;

use think\Model;

class AdminCity extends Model
{
    protected $name = 'admin_city';

    public function getCityName($code = '', $array = [])
    {
        if (!$code) return '';
        $data = $this->where('id', $code)->find();
        if (!$data) return '';
        $array[] = $data->ext_name;
        if ($data->pid !== 0) {
            return $this->getCityName($data->pid, $array);
        }
        return implode('/', array_reverse($array));
    }
}